﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Windows.Forms;

using LowLevelGraphics;
using LowLevelGraphics.Forms;
using LowLevelGraphics.Filter;

namespace ImageRecognition2.Action
{
    /// <summary>
    /// 
    /// </summary>
    public class ActionFishEye : AbstractCommand
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="ActionFishEye"/> class.
        /// </summary>
        public ActionFishEye()
        {
        }

        internal ActionFishEye(ActionFishEye _ActionFishEye)
        {
        }

        /// <summary>
        /// Runs the specified sender.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        public override void Run(object sender, EventArgs e)
        {
            FormParameter formParameter = new FormParameter();
            if (formParameter.ShowDialog() == DialogResult.OK)
            {
                UnsafeBitmap bitmap = MainFormSingleton.ActivePictureBox.BackgroundImage;
                int nCurvature = formParameter.nValue;
                FishEye fishEyeFilter = new FishEye(nCurvature);
                UnsafeBitmap unsafeBitmap = fishEyeFilter.Execute(bitmap);
                unsafeBitmap.Dispose();
            }
        }

        public override object Clone()
        {
            return new ActionFishEye(this);
        }
    }
}
